package gruppe7.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class Html {
	
	public String setHeader(String title)
	{
		String header = "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'" + 
		"'http://www.w3.org/TR/html4/loose.dtd'><html><head><meta http-equiv='Content-Type'" +
		"content='text/html; charset=iso-8859-1'><link href='style.css' rel='stylesheet'" +
		"type='text/css' /><title>PE2 - " + title + "</title></head>";
		return header;
	}
	
	public String setFooter()
	{
		String footer = "<div id ='footer'><p>Portfolio .Exercise and Exam Project v.0.0a Spring 2010 - " +
				"gruppe 7 - Thomas Slott - Daniel Stentsøe - Jacob Vous - Peter Holtegaard - Version 2</p></div></body></html>";
		return footer;
	}
	
	public String LoginFormString(HttpServletRequest req) {
		
		Cookie[] cookies = req.getCookies();
		String username = "";
		String pw ="";
		
		for(Cookie cookie : cookies)
		{			
			if(cookie.getName().equals("Trainstationusername"))
				username = cookie.getValue();
				
			if(cookie.getName().equals("Trainstationpw"))
					pw = cookie.getValue();
		}
			
		String form = "<table class='default'>" +
			"<form action='LoginCheckUser' method='post'>" +
			"<tr><td>Username</td><td><input type='text' name='username' value='" + username + "'/>" +
			"</td><td><input class='radio' type='checkbox' name='remUser'/><label for='remUser'>Remember Username?</label></td></tr>" +
			"<tr><td>Password</td><td><input type='password' name='pw' value='" + pw + "'/></td>" +
			"<td><input class='radio' type='checkbox' name='remPw'><label for='remPw'>Remember Password?</label></td></tr>" +
			"<tr><td></td><td align='right'><input class='submit' type='submit' value='Login'/></td></tr>" +
			"</form>" +
			"</table>";
			
		return form;
	}

}
